package com.sdvdxl.service.impl;

import java.util.List;

import com.sdvdxl.mapper.BlogTypeMapper;
import com.sdvdxl.model.BlogTypeEntity;
import com.sdvdxl.service.BlogTypeService;
import com.sdvdxl.util.ApplicationData;
import com.sdvdxl.util.IdGernater;
import com.sdvdxl.util.JsonResult;

public class BlogTypeServiceImpl implements BlogTypeService {
	private BlogTypeMapper blogTypeMapper;

	public BlogTypeMapper getBlogTypeMapper() {
		return blogTypeMapper;
	}

	public void setBlogTypeMapper(BlogTypeMapper blogTypeMapper) {
		this.blogTypeMapper = blogTypeMapper;
	}

	@Override
	public JsonResult add(BlogTypeEntity blogTypeEntity) {
		JsonResult result = new JsonResult();
		blogTypeEntity.setId(IdGernater.uuid());
		blogTypeMapper.add(blogTypeEntity);
		result.setAttr(blogTypeEntity.getId());
		//更新application中的数据
		ApplicationData.getInstance().updateBlogTypes();
		result.setMsg("添加成功！");
		result.setSuccess(true);
		return result;
	}

	@Override
	public JsonResult del(BlogTypeEntity blogTypeEntity) {
		JsonResult result = new JsonResult();
		blogTypeMapper.del(blogTypeEntity);
		ApplicationData.getInstance().updateBlogTypes();
		result.setMsg("删除成功！");
		result.setSuccess(true);
		return result;
	}

	@Override
	public JsonResult update(BlogTypeEntity blogTypeEntity) {
		JsonResult result = new JsonResult();
		return result;
	}

	@Override
	public BlogTypeEntity get(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<BlogTypeEntity> getAll() {
		return blogTypeMapper.getAll();
	}

}
